package com.yiqi.news.mvp.ui.activity

import android.content.Intent
import android.os.Bundle

import com.jess.arms.base.BaseActivity
import com.jess.arms.di.component.AppComponent
import com.jess.arms.utils.ArmsUtils

import com.yiqi.news.di.component.DaggerRulesComponent
import com.yiqi.news.di.module.RulesModule
import com.yiqi.news.mvp.contract.RulesContract
import com.yiqi.news.mvp.presenter.RulesPresenter

import com.yiqi.news.R
import com.yiqi.news.entity.AgreementVO
import kotlinx.android.synthetic.main.activity_rules.*

class RulesActivity : BaseActivity<RulesPresenter>(), RulesContract.View {

    override fun showAgreementSuccess(errMsg: AgreementVO) {
        btn_backcard_agreement.text = errMsg.drawCashRuleDesc
    }

    override fun showAgreementError(errMsg: String) {
        showMessage(errMsg)
    }

    override fun setupActivityComponent(appComponent: AppComponent) {
        DaggerRulesComponent //如找不到该类,请编译一下项目
                .builder()
                .appComponent(appComponent)
                .rulesModule(RulesModule(this))
                .build()
                .inject(this)
    }


    override fun initView(savedInstanceState: Bundle?): Int {
        return R.layout.activity_rules //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
    }


    override fun initData(savedInstanceState: Bundle?) {
        mPresenter?.doAgreement()
    }


    override fun showMessage(message: String) {
        ArmsUtils.snackbarText(message)
    }

    override fun launchActivity(intent: Intent) {
        ArmsUtils.startActivity(intent)
    }

    override fun killMyself() {
        finish()
    }

    override fun initImmersionBar() {
        super.initImmersionBar()
        mImmersionBar.titleBar(R.id.toolbar).init()
    }

}
